import React, { useCallback, useState } from 'react'

const MyButton = (props) => {
  console.log('11111')
  const testFn = useCallback(() => {
    console.log('2222')
    props.onClick()
  }, [])
  return (
    <button onClick = { testFn }>点击</button>
  )
} 
function App() {
  const [ count, setCount ] = useState(10)
  // const clickHandler = () => {
  //   console.log('点我点我')
  // }

  const clickHandler = useCallback(() => {
    console.log('点我点我')
  }, [])

  return (
    <div>
      <button onClick = { () => {
        setCount(count + 10)
      }}>{ count}</button>
      <MyButton onClick= { clickHandler }></MyButton>
    </div>
  )
}

export default App

